<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
[#include "/WEB-INF/pages/common/taglibs.ftl"]
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title>Insert title here</title>
	<meta name="menu" content="AdminMenu"/>
	<meta name="heading" content="heading"/>
	
	<meta name="form" content="current"/>
	<meta name="mediaurl" content="[@c.url value='/manage/Photo_list.action'][@c.param name='pid' value='${pid}'/][/@c.url]"/>
	<meta name="formurl" content="[@c.url value='/manage/Article_create.action'][@c.param name='pid' value='${pid}'/][/@c.url]"/>
	<meta name="extendsurl" content="[@c.url value='/manage/Extension_create.action'][@c.param name='pid' value='${pid}'/][/@c.url]"/>
	
	<link rel="stylesheet" href="[@c.url value='/js/plugins/jquery-jcrop/jquery.Jcrop.min.css'/]">
	<!-- The localization script
	<script src="[@c.url value='/js/plugins/jquery-fileupload/js/locale.js'/]"></script> -->
	
	<!--图片剪切-->
	<script src="[@c.url value='/js/plugins/jquery-jcrop/jquery.Jcrop.min.js'/]"></script>
	
	<style type="text/css">
		#kcfinder_div {
		    display: none;
		    position: absolute;
		    width: 670px;
		    height: 400px;
		    background: #e0dfde;
		    border: 2px solid #3687e2;
		    border-radius: 6px;
		    -moz-border-radius: 6px;
		    -webkit-border-radius: 6px;
		    padding: 1px;
		    z-index: 1999;
		}
		
	</style>
	
	<script type="text/javascript">
		var base = (function(){
			// 事件绑定
			function _addEventListeners() {
				//初始化缩略图x:y
				//$('#preview').parent('div').width($('#thumb-vx').val());
				//$('#preview').parent('div').height($('#thumb-vy').val());
				
				$('#cutImage').click(function() {
					// 切图的page
					window.open('[@c.url value='/manage/Article_thumb.action'/]',
				        'cut_image', 'status=0, toolbar=0,location=0, menubar=0, ' +
				        'directories=0, scrolling=0, resizable=0, scrollbars=0, width=900, height=600'
				    );
				    window.Thumb = {
						callBack: function(url) {
				            // 图片加载
				            var img = new Image();
				            var base = "${base}";
							//设置图片地址
							img.src = base + url;
							img.onload = function() {
								var img = document.getElementById('thumb');
								img.src = base + url;
								$('#titleImg').val(url);
								img.style.visibility = "visible"; 
							}
						}
					}
					return false;
				});
				
				$('#defaultImage').click(function() {
					// 默认图片加载
					var url = "[@c.url value="${(article.titleImg)!'/images/thumb_80x80.png'}"/]";
		            var img = new Image();
					//设置图片地址
					img.src = url;
					img.onload = function() {
						var img = document.getElementById('thumb');
						img.src = url;
						$('#titleImg').val(url);
						img.style.visibility = "visible"; 
					}
					return false;
				});
			}
			
			function _addImageEventListeners() {
				//选择图片按钮
				$("button[actkey='thumb']").click(function() {
					var actval = $(this).attr('actval');
					// 取得kcfinder所在div
					$div = $('#' + actval);
					$('#titleImg').val('');
			    	//由joiner.js的回调函数自动调用
				    window.KCFinder = {
				    	close: function() {
				    		// 关闭kcfinder
				        	$div.html('').css({display:'none'});
							window.KCFinder = null;
				    	},
				        callBack: function(url) {
					
				            $("input:text[actkey='thumb']").val(url);
				            // 图片加载
				            var img = new Image();
							//设置图片地址
							img.src = base.config.base + url;
							img.onload = function() {
								var img = document.getElementById('thumb');
								img.src = base.config.base + url;
								$('#titleImg').val(url);
								img.style.visibility = "visible"; 
								// 关闭kcfinder
					        	$div.html('').css({display:'none'});
								window.KCFinder = null;
							}
				        }
				    };
				    
				    // 全部缩略图地址:dir=publish_folder
				    $div.html('<iframe name="kcfinder2_iframe" src="[@c.url value="/kcfinder/browse.kc?act=show&type=images&dir=publish_folder"/]" ' +
			        'frameborder="0" width="100%" height="100%" marginwidth="0" marginheight="0" scrolling="no" />');
			    	$div.show();
			    	
			    	return false;
				});
			}
			return {
                config: {
                	url : null,
                    theme: null,
                    base:'${request.contextPath}',
                },
                init: function () {
                	_addEventListeners();
                	_addImageEventListeners();
                }
			}
		}());
	$(function() {
		
		var link = "[@c.url value='/manage/Article_list.action?currentPage=${currentPage}' /]";
			base.config.theme = getTheme();
			base.config.url = link;
            //Initializing the form
			base.init();
	});
	</script>
</head>
<body id="body">
	<!--设置提交行为-->
	[#assign act="save" /]
	[#include "/WEB-INF/pages/manage/Article/_article.ftl"]
</body>
</html>